package classloader;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 
 * Main class, initialization
 * 
 * @author Bulaev_Igor
 *
 */

public class Main {

	private static final String CLASS_NAME = "classloader.TestClass";
	
	public static void main(String[] args) {
		new Main().init();
	}

	/**
	 * 
	 * In this method we cyclically load class file and wait for user input
	 * 
	 */
	
	private void init() {
		Class testClass = null;
		for (;;) {
			try {
				ClassLoader ccl = new CompilingClassLoader();
				testClass = ccl.loadClass(CLASS_NAME);
				System.out.println(testClass.newInstance());
				new BufferedReader(new InputStreamReader(System.in)).readLine();
			} catch (ClassNotFoundException cnfe) {				
				cnfe.printStackTrace();
				break;
			} catch (IllegalAccessException iae) {
				iae.printStackTrace();
				break;
			} catch (InstantiationException ie) {
				ie.printStackTrace();
				break;
			} catch (IOException ioe) {
				ioe.printStackTrace();
				break;
			}
		}
	}

}
